package com.net.shop.car.manager.api.volley.response.oil;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.CardItem;
import com.net.shop.car.manager.api.model.OildCardModel;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;

public class OildCardResponse extends Response {
	private OildCardModel oild;
	CardItem item;
	public ArrayList<CardItem> arrayList;
	public OildCardModel getOild() {
		return oild;
	}

	public void setOild(OildCardModel oild) {
		this.oild = oild;
	}

	public OildCardResponse() {
		super(Constants.LIST_CARD);
		arrayList=new ArrayList<CardItem>();
		// TODO Auto-generated constructor stub
	}

	@Override
	public String getContentTag() {
		return "card";
	}

	public void parseContent(String content) {
		try {
			JSONArray array=new JSONArray(content);
			JSONObject ob=new JSONObject();
			for (int i = 0; i <array.length(); i++) {
				
				ob = array.getJSONObject(i);
				item = new CardItem(ob
						.getString("CARD_NUMBER"), ob
						.getString("CARDHOLDER"), ob
						.getString("CARD_ID"));
				arrayList.add(item);
			}
		
		} catch (JSONException e) {
			e.printStackTrace();
		}
		/*
		JSONObject jb = new JSONObject();
		try {

			jb.put("type", "imicardlist");
			jb.put("member_id", "9");
			JsonObjectRequest jsonRequest = new JsonObjectRequest(NetHelp(jb),
					null, new Response.Listener<JSONObject>() {

						@Override
						public void onResponse(JSONObject response) {
							cancleDialog(response);
							JSONObject jd;
							JSONArray array;
							arrayList = new ArrayList<CardItem>();
							try {
								String str = new String(response.toString()
										.getBytes(), "UTF-8");
								System.out.println("------>"
										+ URLDecoder.decode(str));
								;
								jd = new JSONObject(str);
								array = jd.getJSONArray("card");
								JSONObject ob;
								for (int i = 0; i < array.length(); i++) {

									ob = array.getJSONObject(i);
									item = new CardItem(ob
											.getString("CARD_NUMBER"), ob
											.getString("CARDHOLDER"), ob
											.getString("CARD_ID"));
									System.out.println("========================>"
											+ ob.getString("CARDHOLDER"));
									arrayList.add(item);
								}
								adapter = new OildQuiryAdapter(context,
										arrayList, OildCardDialog.this, i);
								list_qury.setAdapter(adapter);
							} catch (JSONException e) {
								e.printStackTrace();
							} catch (UnsupportedEncodingException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}

						}

					}, new Response.ErrorListener() {

						@Override
						public void onErrorResponse(VolleyError error) {

							System.out.println("网络请求错误==========");
						}

					});
			queue.add(jsonRequest);

		} catch (JSONException e) {
			e.printStackTrace();
		}
*/
	
		

	/*	ArrayList<OilCardDetail> list;
		try {
			JSONObject jd = new JSONObject(content);
			JSONArray array = jd.getJSONArray("info");
			int len = array.length();
			System.out.println("------------>" + len);
			JSONObject ji = (JSONObject) array.get(0);

			JSONObject card = ji.getJSONObject("card");
			list = new ArrayList<OilCardDetail>();
			OilCardDetail oilCardDetail;
			JSONArray huabo = ji.getJSONArray("detial");
			int lenth = huabo.length();
			for (int j = 0; j < lenth; j++) {
				oilCardDetail = new OilCardDetail(
						((JSONObject) huabo.get(j)).getString("HUABO_DATE"),
						((JSONObject) huabo.get(j)).getString("PI_CI"),
						((JSONObject) huabo.get(j)).getString("HUABO_MONEY"));
				list.add(oilCardDetail);
			}

			oild = new OildCardModel(card.getString("SET_MONEY"),
					card.getString("DAO_KUAN_DATE"), card.getString("TYPE"),
					list);
		} catch (JSONException e) {
			e.printStackTrace();
		}
*/
	}

	private class Card {
		private String setMoney;
		private String daokuandate;
		private String type;

	}

	private class detail {
		private String huaboData;
	}

}
